package offer;

import java.util.Arrays;

public interface CanMakeArithmeticProgression {
    boolean canMakeArithmeticProgression(int[] arr);
}
class CanMakeArithmeticProgressionImpl1 implements CanMakeArithmeticProgression{

    /**
     * 朴素解法，时间o(nlogn),排序，然后判断间距
     * @param arr
     * @return
     */
    @Override
    public boolean canMakeArithmeticProgression(int[] arr) {
        boolean ans = true;
        Arrays.sort(arr);
        int n = arr.length;
        int margin = arr[1] - arr[0];
        for (int i = 1; i < n; i++) {
            if(arr[i] - arr[i - 1] != margin){
                ans = false;
                break;
            }
        }
        return ans;
    }
}

class CanMakeArithmeticProgressionImpl2 implements CanMakeArithmeticProgression{
    /**
     *
     * @param arr
     * @return
     */
    @Override
    public boolean canMakeArithmeticProgression(int[] arr) {
        boolean ans = true;
        int n = arr.length;

        return false;
    }
}